var express = require('express');
var path = require('path');
let ico = require("serve-favicon");
var cookieParser = require('cookie-parser');
var logger = require('morgan');

var indexRouter = require('./routes/index');
var usersRouter = require('./routes/users');
// const { response } = require('express');

var app = express();

app.use(ico("./views/favicon.ico"));
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'views')));

app.use('/', indexRouter);
app.use('/users', usersRouter);

app.use((err,request,response,next) => {
    response.send(`警告：${err}`)
})
    
module.exports = app;
